﻿@{
    Layout = "Admin_Layout";
    ViewData["Title"] = "宠物信息";
}
@section Style {
    <style>
        .mydiv .el-form .el-form-item .el-form-item__content, .el-form-item__label {
            font-size: 15px;
            color: black;
            height:10px;
            margin-bottom:5px;
        }

        .mydiv .form-class .el-input__inner {
            width: 200px;
            height:30px;
            padding:4px;
        }

        .el-button-danger{
            height: 28px;
            line-height: 0.4;
            width:80px;
            border: 1px solid #f57d7d;
            border-radius: 2px;
        }

        .el-button-danger span {
            font-family: Microsoft YaHei UI;
            color: #fff;
            font-size: 14px;
            letter-spacing: 1px;
        }

        /* 搜索框 */
        .input-with-select{
            width: 220px;
            padding: 4px;
        }

        /* 下拉框 */
        .my-el-select {
            width: 120px;
            padding:4px;
            margin-right:15px;
        }

        /* selecte 框的高度设置，默认是 40px*/
            .my-el-select .el-input__inner {
            height: 28px;
        }
        /* 下面设置右侧按钮居中 */
            .my-el-select .el-input__suffix {
            top: 4px;
        }

            .my-el-select .el-input__icon {
            line-height: inherit;
        }

            .my-el-select .el-input__suffix-inner {
            display: inline-block;
        }
    </style>
}
<div class="mydiv">
    <div style="float:left;">
        <div style="margin-left:20px;">
            <el-form ref="form" :model="form" :rules="rules" label-width="88px" class="form-class">
                <div style="float:left;">
                        <el-form-item prop="nickName" label="名称">
                        <el-input maxlength="20" v-model.trim="form.nickName" ref="nickName"></el-input>
                    </el-form-item>
                        <el-form-item prop="price" label="价格(元)">
                            <el-input maxlength="6" v-model.trim="form.price" type="number"></el-input>
                    </el-form-item>
                        <el-form-item prop="stock" label="数量">
                        <el-input maxlength="6" v-model.trim="form.stock" type="number"></el-input>
                    </el-form-item>
                        <el-form-item prop="selectedSpeciesItem" label="分类">
                        <el-select v-model="form.selectedSpeciesItem" placeholder="请选择分类">
                                <el-option v-for="item in speciesItems" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                    </el-form-item>
                        <el-form-item prop="age" label="年龄(月)">
                            <el-input maxlength="2" v-model.trim="form.age" type="number"></el-input>
                    </el-form-item>
                    <el-form-item label="性别">
                            <el-radio-group v-model="form.gender">
                                <el-radio :label="1">公</el-radio>
                                <el-radio :label="2">母</el-radio>
                            </el-radio-group>
                    </el-form-item>
                        <el-form-item label="高度(米)">
                            <el-input maxlength="5" v-model.trim="form.height" type="number"></el-input>
                        </el-form-item>
                        <el-form-item label="长度(米)">
                            <el-input maxlength="5" v-model.trim="form.length" type="number"></el-input>
                        </el-form-item>
                        <el-form-item label="体重(公斤)">
                            <el-input maxlength="5" v-model.trim="form.weight" type="number"></el-input>
                        </el-form-item>
                </div>
                <div style="float:left;">
                        <el-form-item label="绝育">
                            <el-radio-group v-model="form.sterStatus">
                            <el-radio :label="1">已绝育</el-radio>
                                <el-radio :label="2">未绝育</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="疫苗">
                            <el-radio-group v-model="form.vaccStatus">
                                <el-radio :label="1">已接种</el-radio>
                                <el-radio :label="2">未接种</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="备注" style="height:50px;">
                            <el-input maxlength="50" v-model.trim="form.remark" type="textarea" resize="none" style="margin-top:6px;" :autosize="{ minRows: 2}"></el-input>
                        </el-form-item>
                        <el-form-item prop="breed" label="品种">
                        <el-input maxlength="20" v-model.trim="form.breed" ref='breed'></el-input>
                        </el-form-item>
                    <div tabindex="1000" ref="resetFocus"></div>
                    <div style="height:141px;margin-left:20px;border:1px solid;border-color:lightgray;margin-top:28px;width:266px;overflow-y: auto;font-size:13px;" id="breedDiv">
                     </div>
                </div>
        </el-form>
         <div style="clear:both;"></div>
    </div>
        <div style="margin-top:20px;">
            <div style="float:left;margin-left:20px;width:256px;">
                <div><img style="width:256px;height:160px;" :src="coverImgUrl" title="请选择图片" /></div>
                <div>
                    <el-upload class="upload"
                               list-type="picture"
                               accept=".jpg , .jpeg , .png"
                               :show-file-list="false"
                               ref="upload"
                               action="string"
                               :file-list="coverImgList"
                               :auto-upload="false"
                               :http-request="uploadFile"
                               :on-change="coverHandleChange"
                               :on-preview="handlePreview" 
                               :on-remove="handleRemove"
                               multiple="false">
                        <el-button slot="trigger" size="small" type="primary" @@click="coverImgFile">封面图片</el-button>
                        <div slot="tip" class="el-upload__tip"><span style="color:red;font-size:13px;margin-right:4px;">*</span>[jpg/jpeg/png图片，小于{{imgSize}}K]</div>
                    </el-upload>
                </div>
            </div>
            <div style="float:left;margin-left:20px;">
                <div>
                    <video width="300" height="160" controls  :src="videoUrl" style="background-color:silver;">
                        <source  type="video/mp4">
                        <source  type="video/avi">
                        <source  type="video/webm">
                        您的浏览器不支持 video 属性。
                    </video>
                </div>
                <div>
                    <el-upload class="upload"
                               accept=".mp4 , .webm"
                               :show-file-list="false"
                               action="string"
                               :file-list="videoList"
                               :auto-upload="false"
                               :on-change="videoHandleChange"
                               multiple="false">
                        <el-button slot="trigger" size="small" type="primary" @@click="videoFile">宠物视频</el-button>
                        <div slot="tip" class="el-upload__tip">[mp4/avi/webm视频，小于{{videoSize}}M]</div>
                    </el-upload>
                </div>
            </div>
        </div>
        <div style="clear:both;"></div>
        <div style="margin-left:20px;margin-top:20px;">
            <div>
                <div style="float:left;"><img style="width:185px;height:160px;" :src="otherImgUrl1" title="请选择图片" /></div>
                <div style="float:left;margin-left:10px;"><img style="width:185px;height:160px;" :src="otherImgUrl2" title="请选择图片" /></div>
                <div style="float:left;margin-left:10px;"><img style="width:185px;height:160px;" :src="otherImgUrl3" title="请选择图片" /></div>
            </div>
            <div style="clear:both;"></div>
            <div>
                <el-upload class="upload"
                           :limit="3"
                           :on-exceed="otherHandleExceed"
                           accept=".jpg , jpeg , .png"
                           :show-file-list="false"
                           list-type="picture"
                           ref="upload"
                           action="string"
                           :auto-upload="false"
                           :file-list="otherImgList"
                           :on-change="otherHandleChange"
                           multiple="true">
                    <el-button slot="trigger" size="small" type="primary" @@click="otherImgFile">其他图片</el-button>
                    <div slot="tip" class="el-upload__tip">[jpg/jpeg/png图片，每张小于{{imgSize}}K]</div>
                </el-upload>
            </div>
        </div>
        <div style="background-color:black;height:1px; border:none;margin-top:15px;"></div>
        <div style="margin-bottom:15px;margin-top:15px;display:none;" id="progressDiv">
            <el-row style="margin-top:8px;display:flex;" :gutter="15">
                <el-col :span="4" style="text-align:right;margin-left:20px;font-size:15px;">
                    提交进度
                </el-col>
                <el-col :span="18">
                    <el-progress :text-inside="true" :stroke-width="20" :percentage="percentage"></el-progress>
                </el-col>
            </el-row>
        </div>
        <div style="margin-left:20px;width:580px;margin-top:15px;">
            <el-button type="primary" :disabled="submitBtnDisabled" @@click="submitForm('form')" style="width:110px;">确 定</el-button>
            <el-button @@click="clearForm" style="width:110px;">清 空</el-button>
        </div>
    </div>
    <div style="background-color:silver;float:left;margin-left:30px;height:400px;width:1px;"></div>
    <div style="float:left;margin-left:30px;max-width:900px;">
        <div style="height:40px;">
            <div style="float:left;padding:4px;"><el-button type="danger" class="el-button-danger" @@click="handleBatchDelete">删除</el-button></div>
            <div style="text-align: right;">
                <div style="float:right;">
                    <div style="float:right;">
                        <el-input placeholder="请输入名称或品种搜索" v-model.trim="searchInput" class="input-with-select" size="mini">
                            <el-button slot="append" icon="el-icon-search" @@click="searchHandle"></el-button>
                        </el-input>
                    </div>
                    <el-select placeholder="请选择分类" v-model="searchSpeciesItem" @@change="searchSpeciesChanged" class="my-el-select">
                        <el-option v-for="item in speciesItemsForSearch" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </div>
            </div>
        </div>
        <div>
            <template>
                <el-table :data="tableData" :row-style="{height: '48px'}" :cell-style="{padding: '0'}"
                          style="width: 100%;border-top:1px solid;border-color:lightgray;font-size:13px;"
                          max-height="800px" @@selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="50" fixed>
                    </el-table-column>
                    <el-table-column
                                     prop="date"
                                     label="日期"
                                     width="140">
                    </el-table-column>
                    <el-table-column prop="nickName"
                                     label="名称"
                                     width="120">
                    </el-table-column>
                    <el-table-column prop="breed"
                                     label="品种"
                                     width="120">
                    </el-table-column>
                    <el-table-column prop="price"
                                     label="价格"
                                     width="80">
                    </el-table-column>
                    <el-table-column prop="stock"
                                     label="数量"
                                     width="50">
                    </el-table-column>
                    <el-table-column prop="species"
                                     label="分类"
                                     width="50">
                    </el-table-column>
                    <el-table-column prop="age"
                                     label="年龄"
                                     width="50">
                    </el-table-column>
                    <el-table-column prop="other"
                                     label="其他"
                                     width="500">
                        <template slot-scope="scope">
                            <div v-html="scope.row.other"></div>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right"
                                     label="操作"
                                     width="160">
                        <template slot-scope="scope">
                            <el-button size="mini"
                            @@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                            <el-button size="mini"
                                       type="danger"
                            @@click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
        </div>
        <div style="">
            <div class="block" style="margin-top:18px;margin-bottom:20px;">
                <el-pagination @@size-change="handleSizeChange"
                               @@current-change="handleCurrentChange"
                               :current-page.sync="currentPageNum"
                               :page-size="pageSize"
                               layout="total, prev, pager, next, jumper"
                               background
                               :total="petInfoCount">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
@section Scripts {
<script>
    var app = new Vue({
        el: "#app",
       mounted: async function () {
           let that = this;//将vue对象的引用保存在that中

           that.breedInfo.forEach((item) => {
               that.addbreedInfo(item);
           });

           that.speciesItemsForSearch.unshift({ "id": "0", "name": "全部" });

           that.getPetInfo(1, '', 0);//获取宠物信息
            $("#app").show();//vue渲染完后显示界面
        },
        methods: {
                //改变种类搜索
           searchSpeciesChanged(value) {
                this.searchSpeciesItem = value;
                this.searchInput = '';
                this.currentPageNum = 1;

                this.getPetInfo(this.currentPageNum, this.searchInput, this.searchSpeciesItem);
            },
            //搜索
                searchHandle(){
                    if (app.searchInput === '') {
                        this.$message.warning('请输入名称或品种搜索');
                        return;
                    }

                    if (app.searchInput.length > 20) {
                        this.$message.warning('搜索内容不能超过20个字符');
                        return;
                    }

                    this.currentPageNum = 1;
                    this.getPetInfo(this.currentPageNum, app.searchInput, this.searchSpeciesItem);//获取宠物信息
                },
                //翻页
                handleCurrentChange(val) {
                    this.getPetInfo(val, this.searchInput, this.searchSpeciesItem);
                },
            //批量删除
            handleBatchDelete() {
                if (this.multipleSelection.length === 0) {
                    this.$message.warning('请选择数据');
                    return;
                }

                let ids = '';
                this.multipleSelection.forEach((item) => {
                    ids += item.petinfoid + '|';
                });

                ids = ids.substring(0, ids.length - 1);

              this.$confirm('此操作将永久删除宠物信息数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    axios.post('../../Admin/AdminHome/DeletePetInfo', {
                        "petInfoIDs": ids,
                    }).then(response => {
                        if (response.data === 'ok') {
                            this.getPetInfo(this.currentPageNum, this.searchInput, this.searchSpeciesItem);//获取宠物信息
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                        }
                    }, error => {
                        alert("错误提示：" + error.message);
                    });

                }).catch(() => {
                });
            },
                //获取分页信息
               getPetInfo(pageNum, searchInput, currentSpecialsNum) {
                    axios.post('../../Admin/AdminHome/GetPaginationInfo', {
                        "pageNum": pageNum,
                        "breedOrNickName": searchInput,
                        "specialsNum": currentSpecialsNum,
                    }).then(response => {
                        this.tableData = response.data.data;
                        this.petInfoCount = response.data.dataCount;

                        this.currentPageNum = pageNum;
                    }, error => {
                        alert("错误提示：" + error.message);
                    });
                },
                //编辑数据
                handleEdit(index, row) {
                    axios.post('../../Admin/AdminHome/GetPetInfoByID', {
                        "petinfoID": row.petinfoid,
                    }).then(async response => {
                        await app.restorePetInfo(response.data);
                    }, error => {
                        alert("错误提示：" + error.message);
                    });
                },
                //单行删除
                handleDelete(index, row) {
                    this.$confirm('此操作将永久删除宠物信息数据, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {

                        axios.post('../../Admin/AdminHome/DeletePetInfo', {
                            "petInfoIDs": row.petinfoid,
                        }).then(response => {
                            if (response.data === 'ok') {
                                this.getPetInfo(this.currentPageNum, this.searchInput, this.searchSpeciesItem);//获取宠物信息
                                this.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                            }
                        }, error => {
                            alert("错误提示：" + error.message);
                        });

                    }).catch(() => {
                        // this.$message({
                        //     type: 'info',
                        //     message: '已取消删除'
                        // });
                    });
                },
                handleSelectionChange(val) {
                    this.multipleSelection = val;
            },
            //编辑时恢复数据
            async restorePetInfo(data) {
                app.form.petinfoid = data.petinfoid;
                app.form.nickName = data.nickname;
                app.form.price = data.price;
                app.form.stock = data.stock;
                app.form.selectedSpeciesItem = data.speciesid;
                app.form.age = data.age;
                app.form.gender = data.gender === '公' ? 1 : 2;
                app.form.height = data.height;
                app.form.length = data.length;
                app.form.weight = data.weight;
                app.form.sterStatus = data.sterstatus === '已绝育' ? 1 : 2;
                app.form.vaccStatus = data.vaccinstatus === '已接种' ? 1 : 2;
                app.form.remark = data.remark;
                app.form.breed = data.breed;

                let URL = window.URL || window.webkitURL;

                //封面
                var vueFileObj = await app.getVueFile("../../Admin/AdminHome/DownFile", data.coverimgsrc);
                app.coverImgList = [];
                app.coverImgList.push(vueFileObj);
                app.coverImgUrl = URL.createObjectURL(vueFileObj.raw);

                //视频
                app.videoUrl = '';
                app.videoList = [];
                if (data.videosrc !== '' && data.videosrc !== null) {
                        app.videoUrl = "/file/" + app.theDomain + "/videos/" + data.videosrc;
                }

                app.otherImgList = [];
                app.otherImgUrl1 = '/img.jpg';
                app.otherImgUrl2 = '/img.jpg';
                app.otherImgUrl3 = '/img.jpg';
                if (data.otherimgsrc !== '' && data.otherimgsrc !== null) {
                    let imgUrls = data.otherimgsrc.split('|');
                    for (var i = 0; i < imgUrls.length; i++) {
                        var imgurl = imgUrls[i];

                            var vueFileObj = await app.getVueFile("../../Admin/AdminHome/DownFile", imgurl);
                        app.otherImgList.push(vueFileObj);

                        if (i === 0)
                            app.otherImgUrl1 = URL.createObjectURL(vueFileObj.raw);
                        else if (i === 1)
                            app.otherImgUrl2 = URL.createObjectURL(vueFileObj.raw);
                        else if (i === 2)
                            app.otherImgUrl3 = URL.createObjectURL(vueFileObj.raw);
                    }
                }
            },
            //添加品种信息
            addbreedInfo(info){
                    $("#breedDiv").append('<span id=\'' + info.id + '\' style="background-color:#DCDCDC;margin:2px;float:left;padding:2px;cursor:pointer;">' + info.name + '</span>');
                $(document).on("click", "#breedDiv #" + info.id, function () {
                     app.$refs.breed.focus();
                     app.form.breed = info.name;
                     app.$refs.resetFocus.focus();
                });
            },
            coverImgFile() {},
            videoFile() {},
            otherImgFile() {
                if (app.otherImgList.length < 3)
                    return;
                // app.otherImgList.splice(1, 1);//删除数组中某位置元素
                // app.otherImgUrl2 = '';
                app.otherImgList = [];
                app.otherImgUrl1 = '/img.jpg';
                app.otherImgUrl2 = '/img.jpg';
                app.otherImgUrl3 = '/img.jpg';
            },
            otherHandleExceed(files, fileList) {
                this.$message.warning('只能选择三张图片');
            },
           coverHandleChange(file, fileList) {

               let isLt10M = file.size / 1024 < this.imgSize;
                    if (!isLt10M) {
                        this.$message.error("图片大小不能超过" + this.imgSize +"KB!");
                        return;
                    }

                    // 限制类型只能为jpg,png
                    let isJPG = file.raw.type === 'image/jpeg';
                    let isPng = file.raw.type === 'image/png';
                    if (!isJPG && !isPng) {
                        this.$message.error("请上传正确格式的图片!");
                        return;
                    }

                    if (fileList.length > 0) {
                        app.coverImgList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件

                        let URL = window.URL || window.webkitURL;
                        app.coverImgUrl = URL.createObjectURL(app.coverImgList[0].raw);
                    }
            },
            videoHandleChange(file, fileList) {

                   let isLt10M = file.size / 1024 / 1024 < this.videoSize;
                    if (!isLt10M) {
                        this.$message.error("视频大小不能超过 " + this.videoSize + "MB!");
                        return;
                    }

                    // 限制类型
                    let isMp4 = file.raw.type === 'video/mp4';
                    let isAvi = file.raw.type === 'video/avi';
                    let isWebm = file.raw.type === 'video/webm';
                    if (!isMp4 && !isAvi && !isWebm) {
                        this.$message.error('请上传正确格式的视频');
                        return;
                    }

                    let URL = window.URL || window.webkitURL;

                    if (fileList.length > 0) {
                        app.videoList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
                        app.videoUrl = URL.createObjectURL(app.videoList[0].raw);
                    }
                },
            otherHandleChange(file, fileList) {

                    let isLt10M = file.size / 1024 < this.imgSize;
                    if (!isLt10M) {
                        this.$message.error("图片大小不能超过" + this.imgSize + "KB!");
                        return;
                    }

                    // 限制类型只能为jpg,png
                    let isJPG = file.raw.type === 'image/jpeg';
                    let isPng = file.raw.type === 'image/png';
                    if (!isJPG && !isPng) {
                        this.$message.error("请上传正确格式的图片!");
                        return;
                    }

                    let URL = window.URL || window.webkitURL;
                    app.otherImgList = fileList;
                    for (var i = 0; i < app.otherImgList.length;i++)
                    { 
                        if (i === 0) {
                            app.otherImgUrl1 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                        else if (i === 1) {
                            app.otherImgUrl2 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                        else if (i === 2) {
                            app.otherImgUrl3 = URL.createObjectURL(app.otherImgList[i].raw);
                        }
                    }
            },
            clearInfo() {
                app.form.petinfoid =-1;
                app.form.nickName = '';
                app.form.price = '';
                app.form.stock = 1;
                app.form.selectedSpeciesItem = '请选择';
                app.form.age = '';
                app.form.gender = 1;
                app.form.height = '';
                app.form.length = '';
                app.form.weight = '';
                app.form.sterStatus = 1;
                app.form.vaccStatus = 1;
                app.form.remark = '';
                app.form.breed = '';

                app.coverImgList = [];
                app.videoList= [];
                app.otherImgList = [];
                app.coverImgUrl = '/img.jpg';
                app.videoUrl = '';
                app.otherImgUrl1 = '/img.jpg';
                app.otherImgUrl2 = '/img.jpg';
                app.otherImgUrl3 = '/img.jpg';
            },
                uploadProgress(progressEvent) {
                    /*
                     * progressEvent.loaded :已上传量
                     * progressEvent.total :上传的总大小
                    */
                    const p = Math.floor((progressEvent.loaded / progressEvent.total) * 100);
                    this.percentage = p;
                },
            //提交窗口
             async submitForm(formName) {
                   if (this.form.selectedSpeciesItem === '请选择') {
                        this.form.selectedSpeciesItem = '';
                    }

                    this.$refs[formName].validate(async (valid) => {
                        if (valid) {

                     //自定义验证
                    if (this.coverImgList.length === 0) {
                        this.$message.warning('封面图片不能为空');
                        return ;
                     }

                    let formData = new FormData();

                    //封面图片
                    for (var i = 0; i < this.coverImgList.length;i++) {
                        formData.append("coverImg"+i, this.coverImgList[i].raw);
                    }

                    //其他图片
                    for (var i = 0; i < this.otherImgList.length; i++) {
                        formData.append("otherImg" + i, this.otherImgList[i].raw);
                    }

                    //视频
                    for (var i = 0; i < this.videoList.length; i++) {
                        formData.append("video" + i, this.videoList[i].raw);
                    }

                    //文字内容
                    var petInfo = {
                        "petinfoid": app.form.petinfoid, "nickName": app.form.nickName, "price": app.form.price, "stock": app.form.stock, "selectedSpeciesItem": app.form.selectedSpeciesItem,
                    "age": app.form.age, "gender": app.form.gender, "height": app.form.height, "length": app.form.length, "weight": app.form.weight,
                    "sterStatus": app.form.sterStatus, "vaccStatus": app.form.vaccStatus, "remark": app.form.remark, "breed": app.form.breed
                     };
                    formData.append("petInfo", JSON.stringify(petInfo));

                            let config = {
                                headers: {
                                    'Content-Type': 'multipart/form-data;charset=utf-8',
                                },
                                transformRequest: [function (data) {
                                    return data
                                }],
                                onUploadProgress: this.uploadProgress,
                            }

                            $("#progressDiv").show();
                            this.submitBtnDisabled = true;

                            await axios.post('../../Admin/AdminHome/AddOrUpdatePetInfo', formData, config).then(res => {
                                let resultData = res.data.split('|');
                                if (resultData[0] === "ok" || resultData[0] === "newbreed") {
                                    this.$message.success('提交成功');

                                    if (resultData[0] === "newbreed") {
                                        this.addbreedInfo({ "id": resultData[1],"name": app.form.breed });
                                    }

                                    this.percentage = 0;
                                    $("#progressDiv").hide();
                                    this.submitBtnDisabled = false;
                                this.clearInfo();
                                this.getPetInfo(this.currentPageNum, this.searchInput, this.searchSpeciesItem);
                            }else {
                                    this.percentage = 0;
                                    $("#progressDiv").hide();
                                    this.submitBtnDisabled = false;
                                    this.$message.warning(res.data);
                            }
                        }, error => {
                                this.percentage = 0;
                                $("#progressDiv").hide();
                                this.submitBtnDisabled = false;
                            alert("错误提示：" + error.message);
                        });


                    } else {
                        console.log('error submit!');
                        return false;
                    }
                });
            },
        },
        data() {
            return {
                    theDomain: '@Html.Raw(ViewData["theDomain"])',
                submitBtnDisabled: false,
                percentage: 0,
                videoSize: @Html.Raw(ViewData["videoSize"]),
                imgSize: @Html.Raw(ViewData["imgSize"]),
                searchSpeciesItem:'0',
                currentPageNum:1,
                pageSize: @Html.Raw(ViewData["pageSize"]),
                petInfoCount:0,
                searchInput:'',
                multipleSelection: [],
                breedInfo: @Html.Raw(ViewData["breedInfo"]),
                defaultMenuActive: '1',
                speciesItems: @Html.Raw(ViewData["speciesList"]),
                speciesItemsForSearch: @Html.Raw(ViewData["speciesList"]),
                coverImgList: [],
                videoList: [],
                otherImgList:[],
               coverImgUrl: '/img.jpg',
               videoUrl: '',
                otherImgUrl1: '/img.jpg',
                otherImgUrl2: '/img.jpg',
                otherImgUrl3: '/img.jpg',
                form: {
                    petinfoid:-1,
                    nickName: '',
                    price: '',
                    stock: 1,
                    selectedSpeciesItem: '',
                    age:'',
                    gender: 1,
                    height:'',
                    length:'',
                    weight:'',
                    sterStatus:1,
                    vaccStatus:1,
                    remark:'',
                    breed:'',
                },
                rules: {
                    nickName: [
                            { required: true, message: '√', trigger: 'blur' }
                    ],
                    price: [
                            { required: true, message: '√', trigger: 'blur' }
                    ],
                    stock: [
                            { required: true, message: '√', trigger: 'blur' }
                    ],
                    selectedSpeciesItem: [
                            { required: true, message: '√', trigger: 'change' }
                    ],
                    age: [
                            { required: true, message: '√', trigger: 'blur' }
                    ],
                    breed: [
                            { required: true, message: '√', trigger: 'blur' }
                    ],
                },
                tableData: [],
            }
        }
    });
</script>
}
